package com.lenovo.vod.player;


import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

public class ContentFragment extends Fragment {
	private View mView;
	private View mBufferView;
	
	/* [s] guo-wj update */
//	private TextView mProgressTextView;
	
	private SurfaceView mSurfaceView;
	private ImageView mBackgroundView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) 
	{
		Log.d(Constant.TAG, "ContentFragment onCreateView called");

		mView = inflater.inflate(R.layout.vodplayer_content, container, false);
		mSurfaceView = (SurfaceView) mView
				.findViewById(R.id.vodplayer_content_surface);
		
		/* [s] guo-wj update */
//		mProgressTextView = (TextView) mView
//				.findViewById(R.id.vodplayer_buffer_progress_text);
		
		mBufferView = (View) mView.findViewById(R.id.vodplayer_buffer_view);
		mBackgroundView = (ImageView) mView
				.findViewById(R.id.vodplayer_background);
		
		hideBuffer();

		// It must be here to make the fragment can get key event
		mView.setFocusable(true);

		return mView;
	}

	public SurfaceView getSurfaceView() {
		return mSurfaceView;
	}

	public void showBuffer(int percent)
	{
		if(mBufferView != null){
			mBufferView.setVisibility(View.VISIBLE);
		}

//		mProgressTextView.setText(percent + "%");
	}

	public void hideBuffer() {
		mBufferView.setVisibility(View.INVISIBLE);
	}

	public void showBackgound() {
		if(mBackgroundView != null){
			mBackgroundView.setVisibility(View.VISIBLE);
		}
	}

	public void hideBackgound() {
		mBackgroundView.setVisibility(View.INVISIBLE);
	}
}
